﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GEMASTIK_NET
{
    public partial class MenuUtama : Form
    {
        DataSet ds = new DataSet();

        public MenuUtama()
        {
            InitializeComponent();
        }

        private void enableTombol()
        {
            this.btnTambah.Enabled = true;
            this.btnUbah.Enabled = true;
            this.btnHapus.Enabled = true;
        }

        private void getData(String tabel)
        {
            //MyData data = new MyData();
            //data.Open();
            //dataGridView1.AutoGenerateColumns = true;
            //ds = data.ExecuteDataSet("SELECT * FROM " + tabel); ;
            //dataGridView1.DataSource = ds;
            //dataGridView1.DataMember = "result";
            //data.Close();
        }

        private void btnDataGuru_click(object sender, EventArgs e)
        {
            dataView.Text = "Data Guru";
            dgv.DataSource = null;
            this.gURUTableAdapter.Fill(this.dSGuru.GURU);
            dgv.DataSource = gURUBindingSource1;
            enableTombol();
        }

        private void btnDataKelas_Click(object sender, EventArgs e)
        {
            dataView.Text = "Data Kelas";
            dgv.DataSource = null;
            enableTombol();
        }

        private void btnDataMataPelajaran_Click(object sender, EventArgs e)
        {
            dataView.Text = "Data Mata Pelajaran";
            enableTombol();
        }

        private void btnDataKurikulum_Click(object sender, EventArgs e)
        {
            dataView.Text = "Data Kurikulum";
            getData("kurikulum");
            enableTombol();
        }

        private void btnPetunjuk_Click(object sender, EventArgs e)
        {
            Petunjuk help = new Petunjuk(this);
            help.Show();
            this.Enabled = false;
        }

        private void btnTimPengembang_Click(object sender, EventArgs e)
        {
            TimPengembang creator = new TimPengembang(this);
            creator.Show();
            this.Enabled = false;
        }

        private void btnTutupAplikasi_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnTambah_Click(object sender, EventArgs e)
        {
            if (this.dataView.Text.Contains("Guru"))
            {
                DataGuru dGuru = new DataGuru("Tambah Data Guru", this);
                dGuru.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kelas"))
            {
                DataKelas dKelas = new DataKelas(this);
                dKelas.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Pelajaran"))
            {
                Data_Mata_Pelajaran dPelajaran = new Data_Mata_Pelajaran(this);
                dPelajaran.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kurikulum"))
            {
                Data_Kurikulum dKurikulum = new Data_Kurikulum(this);
                dKurikulum.Show();
                this.Enabled = false;
            }
        }

        private void btnUbah_Click(object sender, EventArgs e)
        {
            if (this.dataView.Text.Contains("Guru"))
            {
                DataGuru dGuru = new DataGuru("Ubah Data Guru", this);
                dGuru.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kelas"))
            {
                DataKelas dKelas = new DataKelas(this);
                dKelas.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Pelajaran"))
            {
                Data_Mata_Pelajaran dPelajaran = new Data_Mata_Pelajaran(this);
                dPelajaran.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kurikulum"))
            {
                Data_Kurikulum dKurikulum = new Data_Kurikulum(this);
                dKurikulum.Show();
                this.Enabled = false;
            }
        }

        private void btnHapus_Click(object sender, EventArgs e)
        {
            if (this.dataView.Text.Contains("Guru"))
            {
                DataGuru dGuru = new DataGuru("Hapus Data Guru", this);
                dGuru.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kelas"))
            {
                DataKelas dKelas = new DataKelas(this);
                dKelas.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Pelajaran"))
            {
                Data_Mata_Pelajaran dPelajaran = new Data_Mata_Pelajaran(this);
                dPelajaran.Show();
                this.Enabled = false;
            }
            else if (this.dataView.Text.Contains("Kurikulum"))
            {
                Data_Kurikulum dKurikulum = new Data_Kurikulum(this);
                dKurikulum.Show();
                this.Enabled = false;
            }
        }

        private void MenuUtama_Load(object sender, EventArgs e)
        {
            
        }

        private void dataView_VisibleChanged(object sender, EventArgs e)
        {

        }

        private void kELASBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void btnRuang_Click(object sender, EventArgs e)
        {
            Data_Ruangan dRuang = new Data_Ruangan(this);
            dRuang.Show();
            this.Enabled = false;
        }
    }
}
